/**
 * @description 通过指定选择器获取对应节点/节点数组
 * @param { string } selector 选择器
 * @returns 返回节点/节点数组
 */
function $(selector) {
	let nodeList = document.querySelectorAll(selector);
	if (nodeList.length === 0) {
		return console.warn(`${selector}没有获取到`);
	}
	if (nodeList.length === 1) {
		return nodeList[0];
	}
	if (nodeList.length > 1) {
		return nodeList;
	}
}

// 封装选项卡切换函数
function tabs(btns, cards) {
	btns.forEach((v, i) => {
		v.addEventListener("click", () => {
			btns.forEach(function (value, index) {
				value.classList.remove("active");
				cards[index].classList.remove("on");
			});
			v.classList.add("active");
			cards[i].classList.add("on");
		});
	});
}

// 封装点击改变激活效果函数
function changeActive(selectorArr, active) {
	selectorArr.forEach((v) => {
		v.addEventListener("click", () => {
			selectorArr.forEach((each) => {
				each.classList.remove(active);
			});
			v.classList.add(active);
		});
	});
}
